<?php
namespace App\Lib\Qnsdk;
// use Qiniu\Auth;
// use Qiniu\Storage\UploadManager;

include_once('autoload.php');
//
//$accessKey = 'PB0TU6Tx3k3SuuIztN_YzClhV33NtSbvTmDz0x8L';
//$secretKey = 'WkON2t5t1v4Q17RTfJa6Ud0BXefZ6XDg_rtqcJ0g';


function uploadOne($filePath,$bucket='fengquaigou',$accessKey = 'xQv-G5yI2AbxdVhcvDEcj6tlRJ3K6k2Mv4KZhKyA',$secretKey = 'F8r1YmAl08qwmstnluGNO3Q2JYjfSBmSke9zBjDb'){

    $bucket = 'anyuzhe';
// 初始化签权对象
// 空间名  http://developer.qiniu.com/docs/v6/api/overview/concepts.html#bucket
    $auth = new Auth($accessKey, $secretKey);
// 构建 UploadManager 对象
    $uploadMgr = new UploadManager();
// 生成上传Token
    $token = $auth->uploadToken($bucket);
    $key = basename($filePath).rand(10,99);
//        $key = 'test.gif';
//        $filePath = 'yes.gif';
    list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
    echo "\n====> putFile result: \n";
    if ($err !== null) {
        return $err;
    } else {
        return $ret;
    }
}



die;

?>